package com.zr.gdms.serviceimpl;

import java.util.List;

import com.zr.gdms.dao.TeacherDao;
import com.zr.gdms.dao.UserDao;
import com.zr.gdms.daoimpl.TeacherDaoImpl;
import com.zr.gdms.daoimpl.UserDaoImpl;
import com.zr.gdms.model.User;
import com.zr.gdms.service.AdminTeacherService;

import net.sf.json.JSONObject;
/**
 * 管理员查询教师服务实现层
 * @author 李培宁
 *
 */
public class AdminTeacherServiceImpl implements AdminTeacherService{

	TeacherDao tdao = new TeacherDaoImpl();
	UserDao udao = new UserDaoImpl();
	@Override
	public JSONObject getAllTeachers(int page, int rows) {
		JSONObject j = new JSONObject();
		j.put("total", tdao.findTeachersCount());
		j.put("rows", tdao.findAllTeachers(page, rows));
		return j;
	}
	@Override
	public boolean insertTeacher(String tname,String tage,String tdepart,String tprofe,String tsex,String ttel,int uid) {
		// TODO Auto-generated method stub
		return tdao.insertTeacher(tname, tage, tdepart, tprofe, tsex, ttel,uid);
	}
	@Override
	public boolean updateTeacher(String tname,String tage,String tdepart,String tprofe,String tsex,String ttel,int tid) {
		// TODO Auto-generated method stub
		return tdao.updateTeacher(tname, tage, tdepart, tprofe, tsex, ttel, tid);
	}
	@Override
	public boolean deleteTeacher(String apptype, String appstate) {
		// TODO Auto-generated method stub
		return tdao.deleteTeacher(apptype, appstate);
	}
	@Override
	public JSONObject searchTeacherByTid(int page, int rows, int tid) {
		JSONObject jo = new JSONObject();
		jo.put("total", tdao.findTeachersCountByTid(tid));
		jo.put("rows", tdao.searchTeacherByTid(page, rows, tid));
		return jo;
	}
	@Override
	public JSONObject searchTeacherByTname(int page, int rows, String tname) {
		JSONObject jo = new JSONObject();
		jo.put("total", tdao.findTeachersCountByTname(tname));
		jo.put("rows", tdao.searchTeacherByTname(page, rows, tname));
		return jo;
	}
	@Override
	public JSONObject searchTeacherByTsex(int page, int rows, String tsex) {
		JSONObject jo = new JSONObject();
		jo.put("total", tdao.findTeachersCountByTsex(tsex));
		jo.put("rows", tdao.searchTeacherByTsex(page, rows, tsex));
		return jo;
	}
	@Override
	public JSONObject searchTeacherByTdepart(int page, int rows, String tdepart) {
		JSONObject jo = new JSONObject();
		jo.put("total", tdao.findTeachersCountByTdepart(tdepart));
		jo.put("rows", tdao.searchTeacherByTdepart(page, rows, tdepart));
		return jo;
	}
	@Override
	public JSONObject searchTeacherByTprofe(int page, int rows, String tprofe) {
		JSONObject jo = new JSONObject();
		jo.put("total", tdao.findTeachersCountByTprofe(tprofe));
		jo.put("rows", tdao.searchTeacherByTprofe(page, rows, tprofe));
		return jo;
	}
	@Override
	public boolean insertUserByTeacher(String uname, String upsw) {
		// TODO Auto-generated method stub
		return tdao.insertUserByTeacher(uname, upsw);
	}
	

	

}
